var ds_operation = new Ext.data.Store({
	proxy:new Ext.data.HttpProxy({url:'operation_Json_list.action',method:'POST'}),
	reader:new Ext.data.JsonReader({
		root:'operationList',
		totalProperty:'total'},
		[
			{name:'operationId',mapping:'operationId',type:'short'},
			{name:'operationName',mapping:'operationName',type:'string'},
			{name:'operationURL',mapping:'operationURL',type:'string'}
		]
	)
});

var cm_operation=new Ext.grid.ColumnModel([
	new Ext.grid.RowNumberer(),
	{header:'操作名称',dataIndex:'operationName',width:400,sortable:true},
	{header:'操作URL',dataIndex:'operationURL',width:400,sortable:true}
]);

var import_button = new Ext.Button({
	text : '导入权限',
	hidden:true,
	width : 100,
	iconCls:'operation_in',
	handler : function() {
			Ext.Msg.confirm('确认导入', '你确定从XML中导入操作?', function(btn) {
				if (btn == 'yes') {
					Ext.Ajax.request({
						url : 'operation_Import.action',
						method : 'post',
						success : function(resp,opts) {
							var respText = Ext.util.JSON.decode(resp.responseText);
							if(respText.success){
								Ext.Msg.show({
									title : '操作提示',
									msg : '导入成功',
									buttons : Ext.Msg.OK,
									icon : Ext.Msg.INFO,
									width : 200
								});
								ds_operation.load({params:{start:0,limit:20}});
							}else{
								Ext.Msg.show({
									title : '错误提示',
									msg : '导入失败!',
									buttons : Ext.Msg.OK,
									icon : Ext.Msg.ERROR,
									width : 200
								})
							}
						},
						failure : function() {
                            Ext.Msg.show({
								title : '错误提示',
								msg : '导入失败!',
								buttons : Ext.Msg.OK,
								icon : Ext.Msg.ERROR,
								width : 200
							});
						}
					});
				}
			});
	}
});

var grid_operation = new Ext.grid.GridPanel({
	title : '当前位置：权限管理',
	loadMask : {msg : '数据加载中...'},
	ds:ds_operation,
	store:ds_operation,
	region : 'center',
	autoScroll: true,
	cm:cm_operation,
	autoExpandColumn : 2,
	tbar : [import_button],
	bbar : new Ext.PagingToolbar({
		pageSize : 20,
		store : ds_operation,
		displayInfo : true,
		beforePageText:'第',
		afterPageText:'页-共{0}页',
		displayMsg : '显示{0} - {1} 条  共 {2} 条',
		emptyMsg : "没有记录"
	})
});
ds_operation.load({params:{start:0,limit:20}});
var l_operation = {
	id : 'operation-search',
	border : false,
	layout : 'border',
	items : [grid_operation]
};
Ext.getCmp('content-panel').add(l_operation);
Ext.getCmp('content-panel').layout.setActiveItem('operation-search');